package com.other;

import java.util.Scanner;

public class MeiTuan {

    // 用于操作最优数组
    private static int operateNum( int[][] operates, int[] nums){
        Scanner sc = new Scanner(System.in);
        int sum=0;
        int opeLen = operates.length;
        System.out.println("\n写入操作数组：\n");
        // 写入操作数组
        for (int i = 0; i < opeLen; i++) {
            operates[i][0] = sc.nextInt();
            for (int j = 1; j <= (operates[i][0] == 1 ? 2 : 3); j++) {
                operates[i][j] = sc.nextInt();
            }
            // 操作
            if (operates[i][0] == 1) {
                for (int j = operates[i][1] - 1; j <= operates[i][2] - 1; j++) {
                    sum += nums[j];
                }
            } else {
                for (int j = operates[i][1] - 1; j <= operates[i][2] - 1; j++) {
                    nums[j] += operates[i][3];
                }
            }
        }
        return sum;
    }

    private static int toResult() {
        int numLen, opeLen;
        Scanner sc = new Scanner(System.in);
        System.out.println("输入数组长度和操作次数：\n");
        numLen = sc.nextInt();
        opeLen = sc.nextInt();
        int[] nums = new int[numLen];
        int[][] operates = new int[opeLen][numLen];
        int sum = 0;
        System.out.println("\n写入原数组：\n");
        // 写入原数组
        for (int i = 0; i < numLen; i++) {
            nums[i] = sc.nextInt();
        }
        // 处理原数组得出最优数组
        /*
        ......
         */
        return operateNum(operates, nums);
    }

    public static void main(String[] args) {
        System.out.println(toResult());
    }
}
